package com.qs.eggs.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.qs.eggs.Constants;
import com.qs.eggs.R;
import com.qs.eggs.bean.SortBean;
import com.qs.eggs.refresh.adapter.BaseRecyclerAdapter;


import java.util.ArrayList;
import java.util.List;


public class SortAdapter extends BaseRecyclerAdapter<SortBean> implements BaseRecyclerAdapter.OnLoadingHeaderCallBack {


    public SortAdapter(Context context, int mode) {
        super(context, mode);

        setOnLoadingHeaderCallBack(this);
    }

    @Override
    public RecyclerView.ViewHolder onCreateHeaderHolder(ViewGroup parent) {
        return new HeaderViewHolder(mHeaderView);
    }

    @Override
    public void onBindHeaderHolder(RecyclerView.ViewHolder holder, int position) {

    }

    @Override
    protected RecyclerView.ViewHolder onCreateDefaultViewHolder(ViewGroup parent, int type) {
        return new SortViewHolder(mInflater.inflate(R.layout.item_sort, parent, false));
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, SortBean item, int position) {
        final SortViewHolder vh = (SortViewHolder) holder;

        vh.mProName.setText(item.getProtypename());
        vh.mProPrice.setText("￥"+item.getSaleprice());
        vh.mAvatar.setImageURI(Constants.URL_BASE+"productimages/"+item.getAutoname());

    }
    private static class SortViewHolder extends RecyclerView.ViewHolder {
        TextView mProName,mProPrice;
        ImageView mCollect;
        SimpleDraweeView mAvatar;


        public SortViewHolder(View itemView) {
            super(itemView);

            mProName=(TextView) itemView.findViewById(R.id.tv_proname);
            mProPrice=(TextView) itemView.findViewById(R.id.tv_proprice);
            mAvatar=(SimpleDraweeView) itemView.findViewById(R.id.propic);
        }
    }
}
